﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using TestArgoProjectsService.ArgoProjectsService;

namespace TestArgoProjectsService
{
    class Program
    {
        private static ArgoProjectsService.ArgoProjectsServiceClient client;

        /// <summary>
        /// argointegration\administrator
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            try
            {
                client = new ArgoProjectsService.ArgoProjectsServiceClient();
                client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

                //client.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;  
                //janedoe



                client.ChannelFactory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential("Administrator", "123abc?!", "argointegration");


                GetFolderStructure(0);

                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }

        }

        private static void GetFolderStructure(int projectId)
        {
            ProjectFolder[] pf = client.GetFolderStructure(projectId);

            foreach (ProjectFolder folder in pf)
            {
                Console.WriteLine(folder.Name);
            }

            pf[0].Children[0].ParentFolderId = Guid.NewGuid();

        }

        private static void WriteReadSettings()
        {
            Dictionary<string, string> allSettings = client.TestReadAllSettingsSetting();
            foreach (KeyValuePair<string, string> setting in allSettings)
            {
                Console.WriteLine(setting.Key + " ----- " + setting.Value);
            }

        }

        private static void SearchFiles()
        {
            ArgoSearchResult[] foundFiles = client.SearchRepository("Lorem ipsum");

            foreach (ArgoSearchResult file in foundFiles)
            {
                Console.WriteLine(file.FileName);
            }
        }
    }
}
